package com.xmg.unsafe;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

public class UnSafeAccess {
    private final static Unsafe unsafe;

    static {
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
            unsafe = (Unsafe)theUnsafe.get(null);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }

    public static Unsafe getUnsafe(){
        return unsafe;
    }
}
